package com.cat.binaryTree;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/binary-search-tree-to-greater-sum-tree/
 * @create 2025/9/14 15:48
 * @since JDK17
 */

public class Solution36 {
    int ans;
    public TreeNode bstToGst(TreeNode root) {
        if (root == null) {
            return null;
        }
        bstToGst(root.right);
        ans += root.val;
        root.val = ans;
        bstToGst(root.left);
        return root;
    }
}
